//
//  UIBarButtonItem+XDItem.m
//  XDEducation
//
//  Created by Ethan on 2017/5/15.
//  Copyright © 2017年 apple. All rights reserved.
//

#import "UIBarButtonItem+XDItem.h"

@implementation UIBarButtonItem (XDItem)
+ (instancetype)itemWithImage:(NSString *)image highImage:(NSString *)highImage target:(id)target action:(SEL)action
{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [button setBackgroundImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
    [button setBackgroundImage:[UIImage imageNamed:highImage] forState:UIControlStateHighlighted];
    button.contentMode = UIViewContentModeCenter;
    button.size = [UIImage imageNamed:image].size;
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    return [[self alloc] initWithCustomView:button];
}
+ (instancetype)itemWithImages:(NSString *)image highImage:(NSString *)highImage target:(id)target action:(SEL)action{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [button setImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
    [button setImage:[UIImage imageNamed:highImage] forState:UIControlStateHighlighted];
    button.contentMode = UIViewContentModeCenter;
    button.bounds = CGRectMake(0, 0, 30, 40);
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    return [[self alloc] initWithCustomView:button];
    
}
+ (instancetype)itemWithImages:(NSString *)image seleteImage:(NSString *)seleteImage target:(id)target action:(SEL)action{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [button setImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
    [button setImage:[UIImage imageNamed:seleteImage] forState:UIControlStateSelected];
    button.contentMode = UIViewContentModeCenter;
    button.bounds = CGRectMake(0, 0, 30, 40);
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    return [[self alloc] initWithCustomView:button];
    
}
+ (instancetype)itemWithTitle:(NSString *)str andTitleColor:(UIColor *)titleColor andSeleteTitle:(NSString *)seleteStr andSeleteTitleColor:(UIColor *)seleteTitleColor target:(id)target action:(SEL)action{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setTitle:str forState:UIControlStateNormal];
    [button setTitle:seleteStr forState:UIControlStateSelected];
    [button setTitleColor:titleColor forState:UIControlStateNormal];
    [button setTitleColor:seleteTitleColor forState:UIControlStateSelected];
    button.contentMode = UIViewContentModeCenter;
    button.bounds = CGRectMake(0, 0, 70, 40);
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    return [[self alloc] initWithCustomView:button];
    
}
+ (instancetype)itemWithTitle:(NSString *)str andTitleColor:(UIColor *)titleColor andFont:(UIFont *)font andWidth:(CGFloat)width andSeleteTitle:(NSString *)seleteStr andSeleteTitleColor:(UIColor *)seleteTitleColor target:(id)target action:(SEL)action{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setTitle:str forState:UIControlStateNormal];
    [button setTitle:seleteStr forState:UIControlStateSelected];
    [button setTitleColor:titleColor forState:UIControlStateNormal];
    button.titleLabel.font = font;
    [button setTitleColor:seleteTitleColor forState:UIControlStateSelected];
    button.contentMode = UIViewContentModeCenter;
    button.bounds = CGRectMake(0, 0, width, 40);
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    return [[self alloc] initWithCustomView:button];
    
}

@end
